//
//  YGJOrderVC.m
//  ygj-customer-iOS
//
//  Created by apple on 16/11/10.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "YGJOrderVC.h"
#import "UIColor+Hex.h"

//获取设备屏幕尺寸
#define SCREEN_WIDTH ([UIScreen  mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

@interface YGJOrderVC ()

@end

@implementation YGJOrderVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor purpleColor];

    [self setNavgationBarButton];
    
//    self.navigationItem.titleView = self.segmentControl;
    _segmentControl = [[HMSegmentedControl alloc] initWithFrame:CGRectMake(0, 60, SCREEN_WIDTH, 44)];
    _segmentControl.selectedSegmentIndex = 0;
    _segmentControl.titleTextAttributes = @{NSFontAttributeName : [UIFont systemFontOfSize:14],NSForegroundColorAttributeName : [UIColor lightGrayColor]};
    _segmentControl.selectedTitleTextAttributes = @{NSFontAttributeName : [UIFont systemFontOfSize:14],NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#0093ff"]};
    _segmentControl.selectionStyle = HMSegmentedControlSelectionStyleFullWidthStripe;
    _segmentControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown;
    _segmentControl.selectionIndicatorColor = [UIColor colorWithHexString:@"#0093ff"];
    _segmentControl.selectionIndicatorHeight = 2;
    _segmentControl.sectionTitles = @[@"当前订单",@"历史订单"];
    [self.view addSubview:_segmentControl];
}

#pragma mark seg
- (HMSegmentedControl *)segmentControl{
    if (!_segmentControl) {
        
        
//                [Tools setBorderWithView:_segmentControl];
    }
    return _segmentControl;
}

#pragma mark 设置导航栏左右按钮
-(void) setNavgationBarButton {
    UIBarButtonItem * rightItem = [[UIBarButtonItem alloc] initWithTitle:@"长期订单" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction)];
    self.navigationItem.rightBarButtonItem = rightItem;
    
}

#pragma mark 导航栏按钮事件

-(void) rightAction {
    NSLog(@"点击---->订单右侧导航按钮");
    
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    
    CGFloat pageWidth = scrollView.frame.size.width;
    NSInteger page = scrollView.contentOffset.x / pageWidth;
    [self.segmentControl setSelectedSegmentIndex:page animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
